ALLIANCE_TOP	= /opt/alliance-5.0

ENV_ASIMUT	= MBK_CATAL_NAME=CATAL_ASIMUT

ENV_COUGAR	= MBK_SPI_MODEL=$(ALLIANCE_TOP)/etc/spimodel.cfg ;\
		  export MBK_SPI_MODEL;\
		  MBK_IN_PH=ap ;\
		  export MBK_IN_PH;\
		  MBK_OUT_LO=spi;\
		  export MBK_OUT_LO


all: pc.vbe check-behavioral synthesis check-synthesis place-route transistors

check-behavioral: test_pc.pat result_sim.pat

synthesis: pc_boom.vbe pc_boog.vst pc_loon.vst

check-synthesis: test_pc.pat result_syn.pat

place-route: synthesis pc_ocp.ap pc_nero.ap pc_real.cif

transistors: place-route pc_transistors.spi

view-behav: result_sim.pat
	xpat -l result_sim 

view-gates: pc_loon.vst
	xsch -l pc_loon

view-place: synthesis pc_ocp.ap
	graal -l pc_ocp

view-route: synthesis pc_nero.ap
	graal -l pc_nero

view-real: synthesis pc_real.cif
	dreal -l pc_real

spice-pc: pc_transistors.spi
	$(ENV_COUGAR); xsch -I spi -l pc_transistors

##################################################################################
##################################################################################
	
pc.vbe: pc.vhdl
	@echo "Conversion del archivo vhdl a vbe"
	@echo "================================="
	vasy -Vaop -I vhdl pc.vhdl

test_pc.pat: test_pc.c
	genpat test_pc

result_sim.pat: pc.vbe test_pc.pat
	@echo "Simulando el decodificador"
	@echo "================================="
	asimut -b pc test_pc result_sim 

pc_boom.vbe: pc.vbe
	@echo "Inicio de la etapa de synthesis"
	@echo "================================="
	boom pc pc_boom

pc_boog.vst: pc_boom.vbe
	boog pc_boom pc_boog

pc_loon.vst: pc_boog.vst
	loon -o pc_boog pc_loon

result_syn.pat: pc_loon.vst test_pc.pat
	@echo "Simulando los archivos generados en la etapa de sintesis"
	@echo "========================================================"
	asimut pc_loon test_pc result_syn

pc_ocp.ap: pc_loon.vst
	@echo "Inicio de la etapa de place and route"
	@echo "====================================="
	ocp pc_loon pc_ocp

pc_nero.ap: pc_ocp.ap pc_loon.vst
	nero -p pc_ocp pc_loon pc_nero

pc_real.cif: pc_nero.ap
	s2r pc_nero pc_real

pc_transistors.spi: pc_nero.ap
	$(ENV_COUGAR); cougar -t pc_nero pc_transistors

clean:
	rm -rf	*~ \
	*.vbe \
	*.vst \
 	*.ap \
	*.cif \
	*.xsc \
	*.pat \
	*.dat \
	*.spi \
	*#
